home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
dte5_1.zip
/
HWHPXL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-02-06
|
50KB
|
1,589 lines
/*
* Written by Douglas Thomson (1989/1990)
*
* This source code is released into the public domain.
*/
/*
* Name: dte - Doug's Text Editor program - hardware dependent module
* Purpose: This file contains all the code that needs to be different on
* different hardware.
* File: hwhpxl.c (actually HWHPXLC due to naming restrictions)
* Author: Douglas Thomson
* System: This particular version is for the HP3000 running MPE/XL.
* Date: October 10, 1989
* Notes: This module has been kept as small as possible, to facilitate
* porting between different systems.
* This is a preliminary version, which does not support any
* way to find out whether a character has been typed without
* waiting for it. There seems to be no simple way to do this.
* I tried using NOWAIT I/O on $STDIN, but it seems that a
* pending read (even a NOWAIT read) prevents any further output
* to the terminal!!!
* Because of this, it is very important to use what HP call a
* type ahead engine. This is supplied in a file called:
* TYPE.DTS0000.TELESUP
* and the required command is:
* TYPE.DTS0000.TELESUP ON
* which enables type ahead for all subsequent programs. HP
* have some justification for not making this the default,
* but I confess I could not follow their logic.
* Without type ahead, "dte" loses keystrokes all over the place!
*/
#include "commonh" /* dte types */
#include "hwdeph" /* prototypes for functions here */
#include "utilsh" /* for displaying messages etc */
#include "versionh" /* current version number */
#include <mpe.h> /* access to MPE intrinsics */
#include <varargs.h> /* for passing variable numbers of parameters */
#include <fcntl.h> /* for open flags */
/*
* prototypes for all functions in this file
*/
static void myputchar ARGS((char c));
static void myputs ARGS((char *s));
void error ARGS((int kind, ...));
static void termset ARGS((char *name));
void main ARGS((int argc, char *argv[]));
static void hw_attr ARGS((char attr));
static void att_stuff ARGS((void));
void att_check ARGS((void));
void hw_xygoto ARGS((void));
int hw_clreol ARGS((void));
int hw_linedel ARGS((int line));
int hw_scroll_up ARGS((int top, int bottom));
int hw_lineins ARGS((int line));
int hw_scroll_down ARGS((int top, int bottom));
int hw_c_avail ARGS((void));
int hw_c_input ARGS((void));
void hw_c_output ARGS((int c));
void hw_terminate ARGS((void));
void hw_initialize ARGS((void));
void hw_move ARGS((text_ptr dest, text_ptr source, long number));
int hw_backspace ARGS((void));
int hw_c_insert ARGS((void));
int hw_c_delete ARGS((void));
int hw_rename ARGS((char *old, char *new));
int hw_fattrib ARGS((char *name));
int hw_set_fattrib ARGS((char *name, int attrib));
int hw_unlink ARGS((char *name));
int hw_printable ARGS((int c));
int hw_load ARGS((char *name, text_ptr start, text_ptr limit, text_ptr *end));
static int write_file ARGS((char *name, char *mode, text_ptr start,
text_ptr end));
int hw_save ARGS((char *name, text_ptr start, text_ptr end));
int hw_append ARGS((char *name, text_ptr start, text_ptr end));
int hw_print ARGS((text_ptr start, text_ptr end));
void hw_copy_path ARGS((char *old, char *name, char *new));
/*
* These pragmas provide access to system intrinsics necessary mainly
* for direct keyboard input.
*/
#pragma intrinsic COMMAND MPE_COMMAND
#pragma intrinsic FFILEINFO MPE_FFILEINFO
#pragma intrinsic FCONTROL MPE_FCONTROL
#pragma intrinsic FDEVICECONTROL MPE_FDEVICECONTROL
#pragma intrinsic FREAD MPE_FREAD
#pragma intrinsic FWRITE MPE_FWRITE
#pragma intrinsic FRENAME MPE_FRENAME
#pragma intrinsic HPCIPUTVAR MPE_PUTVAR
#define REVERSE 1 /* reverse video (or standout) attribute */
#define HIGH 2 /* high intensity (or underline) attribute */
#define NORMAL 3 /* normal video attribute */
/*
* The following variables store the appropriate escape sequences for
* the current terminal type. This is not very elegant coding, although
* the problem with global variables is at least restricted to just this
* one source file.
* Eventually it would be nice to implement some equivalent to a UNIX
* termcap file...
*/
static char *t_flash1; /* start flash attribute */
static char *t_flash0; /* end flash attribute */
static char *t_block1; /* start block attribute */
static char *t_block0; /* end block attribute */
static char *t_eol; /* erase to end of line */
static char *t_insline; /* insert line */
static char *t_delline; /* delete line */
static char *t_inschar; /* insert character */
static char *t_delchar; /* delete character */
static char *t_defwind; /* define scrollable window */
static char *t_scrup; /* scroll window up */
static char *t_scrdown; /* scroll window down */
static char *t_cp; /* cursor positioning */
static int t_cpoff; /* cursor positioning offset */
static int t_hptinit; /* set up HP (700/41) terminal function keys? */
/*
* Under MPE/XL, text files can either have variable length lines or fixed
* length lines. For most purposes (such as program source files) using
* variable length lines saves wasting space. However, MPE/XL insists that
* job files have fixed length lines. Therefore, the editor must be able to
* create either kind of file.
* This is achieved by checking the name of the executing program: DTE implies
* variable length lines, DTEJ implies fixed length lines.
* The "g_job_file" variable is set TRUE if we are working with job files.
*/
int g_job_file;
/*
* the following variable determines the size of the memory buffer used. It
* is set to something reasonable in main.
*/
static int g_space = 0;
/*
* Name: myfflush
* Purpose: To flush any pending characters in the output buffer.
* Date: September 3, 1990
*/
static void myfflush()
{
fflush(stdout);
}
/*
* Name: myputchar
* Purpose: To output a single character to the display device.
* Date: September 3, 1990
* Passed: c: the character to be output
*/
static void myputchar(c)
char c;
{
putc(c, stdout);
}
/*
* Name: myputs
* Purpose: To output a character string to the display device.
* Date: November 6, 1989
* Passed: s: the character string to be output
*/
static void myputs(s)
char *s;
{
while (*s) {
myputchar(*s++);
}
}
/*
* Name: error
* Purpose: To report an error, and usually make the user type <ESC> before
* continuing.
* Date: October 10, 1989
* Passed: kind: an indication of how serious the error was:
* TEMP: merely a message, do not wait for <ESC>
* DIAG: merely a message, but make sure user sees it
* WARNING: error, but editor can continue after <ESC>
* FATAL: abort the editor!
* format: printf format string for any arguments that follow
* ...: arguments to be printed
* Notes: This function should be system independent; that is the whole
* point of the "stdarg" philosophy. However, two of the systems
* I have used implemented "stdarg" incompatibly, and some older
* systems may not support the "stdarg" macros at all...
*/
void error(kind, va_alist)
int kind;
va_dcl
{
char *format; /* printf format string for error message */
va_list argptr; /* used to access various arguments */
char buff[MAX_COLS]; /* somewhere to store error before printing */
int c; /* character entered by user to continue */
/*
* obtain the first two arguments
*/
va_start(argptr);
format = va_arg(argptr, char *);
/*
* tell the user what kind of an error it is
*/
switch (kind) {
case FATAL:
strcpy(buff, "Fatal error: ");